package university;

import university.exceptions.ListEmptyException;

import java.util.ArrayList;

/**
 * Class that describes group's curriculum
 * @author anatolii.bondarenko.
 */
class CurriculumForGroup {
    private Group group;
    private ArrayList<Discipline> disciplines;
    private ArrayList<Integer> theoreticalHours;
    private ArrayList<Integer> practicalHours;
    /**
     * Object is group's curricculum
     * @param g desired group
     * @param d list of disciplines for desired group for current semester
     * @param th amount of hours for theoretical classes
     * @param ph amoount of hours for practical classes
     */
    public CurriculumForGroup(Group g, ArrayList<Discipline> d, ArrayList<Integer> th, ArrayList<Integer> ph) throws ListEmptyException {
        group = g;
        disciplines = d;
        theoreticalHours = th;
        practicalHours = ph;
        if (d.size()==0){
            throw new ListEmptyException("No disciplines in curriculum");
        }
        if (th.size()==0){
            throw new ListEmptyException("No theoretical classes in curriculum");
        }
        if (ph.size()==0){
            throw new ListEmptyException("No practical classes in curriculum");
        }
    }

    /**
     * Rerurns curriculum in some sort of table format(format of table TBD)
     * @return curricculum
     */
    public String getCurriculum(){
        String s;
        if (disciplines.size() == theoreticalHours.size() && disciplines.size() == practicalHours.size()){
            s = "Curriculum for group" + group.getGroupName() + ":\n" + "\tDiscipline\t\ttheoretical hours\tpractical hours\n";
            for (int i = 0; i < disciplines.size(); i++){
                s = s + "\t" + disciplines.get(i).getDisciplineName() + "\t" + theoreticalHours.get(i) + "\t\t\t\t\t" + practicalHours.get(i) + "\n";
            }
        }
        else {
            s = "Invalid curriculum data was entered";
        }
        return s;
    }


}

